/**
 * 入口方法
 */
import Vue from 'vue';
import VueRouter from 'vue-router';
import ViewUI from 'view-design';
import App from './components/layout/index.vue';
// import getMenuRouterData from './menu-router';
import Routers from './router';
import store from './store/index';

Vue.use(VueRouter);
Vue.use(ViewUI);

// 将store作为全局变量
Vue.prototype.$store = store;

// 路由配置
const RouterConfig = {
  mode: 'history',
  routes: Routers
};
const router = new VueRouter(RouterConfig);

// LoadingBar,加载进度条
router.beforeEach((to, from, next) => {
  ViewUI.LoadingBar.start();
  next();
});

router.afterEach((to, from, next) => {
  ViewUI.LoadingBar.finish();
  window.scrollTo(0, 0);
  console.log("路由滚动 ", to, from, next);
});

new Vue({
  el: '#app',
  router: router,
  render: h => h(App)
});